<template>
  <div class="wrapper">
    <div class="traffic">
      <img src="@/assets/img/time.png" alt="" />
      <div class="List">
        <div class="Item">{{ traffic.businessHours[0] }}</div>
      </div>
    </div>
    <div class="traffic" v-if="busList.length !== 0">
      <img src="@/assets/img/bus.png" alt="" />
      <div class="List">
        <div class="Item" v-for="item in busList" :key="item">{{ item }}</div>
      </div>
    </div>
    <div class="traffic" v-if="subwayList.length !== 0">
      <img src="@/assets/img/subway.png" alt="" />
      <div class="List">
        <div class="Item" v-for="item in subwayList" :key="item">{{ item }}</div>
      </div>
    </div>
  </div>
</template>
<script>
import { reactive, toRefs } from "@vue/reactivity";
import { onBeforeMount } from "@vue/runtime-core";
export default {
  props: ["traffic"],
  setup(props) {
    const state = reactive({
      busList: [],
      subwayList: [],
    });
    onBeforeMount(() => {
      state.busList = props.traffic.transport.bus;
      state.subwayList = props.traffic.transport.subway;
    });
    return { ...toRefs(state) };
  },
};
</script>
<style lang="less" scoped>
.wrapper{
  margin-bottom: 40px;
}
.traffic {
  box-sizing: border-box;
  display: flex;
  width: 100%;
  padding: 10px;
  img {
    width: 20px;
    height: 20px;
  }
  .List {
    flex: 1;
    // background: red;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    .Item {
      flex: 1;
      font-size: 15px;
      font-weight: 700px;
    }
  }
}
</style>
